<?php include 'DBManager.class.php';

	$db = new DBManager ( 'localhost', 'root', '', 'iumus' );
	
	extract ( $_POST );
	
	$seed = rand ( 10000 , 99999 );
	$params = '?username='.$username.'&seed='.$seed;
	
	$v = explode ( "/", $_SERVER['SCRIPT_NAME'] );
	$link = 'http://'.$_SERVER['SERVER_NAME'].'/'.$v[1].'/';
	$link .= 'confirmRegistration.php'.$params;
	
	//change this to your email. 
    $to = $mail; 
    $from = "admin@broadcastwwm.com"; 
    $subject = "Registrazione BroadCastWorldWideMedia"; 

    //begin of HTML message 
    $message = '';
	$message .= 	'<html>';
	$message .= 	  '<body>'; 
	$message .= 		'<center>';
	$message .= 			'Hi '.$name.' '.$surname.', to confirm the registration to the site follow the BroadCastWorldWideMedia ';
	$message .= 			'<a href="'.$link.'">Link</a>';
	$message .= 		'</center>';
	$message .= 	  '</body>';
	$message .= 	'</html>';

   //end of message 
    $headers  = "From: $from\r\n"; 
    $headers .= "Content-type: text/html\r\n"; 

    //options to send to cc+bcc 
    //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; 
    //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; 
     
    // now lets send the email. 
    mail($to, $subject, $message, $headers); 
	
	$query = "INSERT INTO `iumus`.`utente` ( `Username` , `Password` , `Nome` , `Cognome` , `Email`, `Activated` ) VALUES ";
	$query .= "( '".$username."',  '".md5 ( $pass )."',  '".$name."',  '".$surname."',  '".$mail."',  '".$seed."' )";
	
	$result = $db->executeQuery ( $query );
	
	header("Location: ../../confirmUserRegistration.php");
?>